package com.h2cloud.depends;

import com.google.gson.Gson;

import java.util.Map;

/**
 * @author: wulongkai
 * @create: 2022-10-10 16:11
 **/
public class JsonUtil {
    public JsonUtil() {
    }

    public static String toJson(Object obj) {
        Gson gson = new Gson();
        return gson.toJson(obj);
    }

    public static <T> T fromJson(String json, Class<T> clazz) {
        Gson gson = new Gson();
        return gson.fromJson(json, clazz);
    }

    public static <T> String mapToJson(Map<String, T> map) {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(map);
        return jsonStr;
    }
}
